package com._520it.crm.web.controller;

import java.util.List;

import com._520it.crm.domain.Owner;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com._520it.crm.domain.Recognizee;
import com._520it.crm.service.IRecognizeeService;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class RecognizeeController {
	@Autowired
	private IRecognizeeService service;

	@RequestMapping("/recognizee/index")
	public String index() {
		return "recognizee/index";
	}

	@RequestMapping("/recognizee_selectAll")
	@ResponseBody
	public List<Recognizee> selectAll() {
		return service.selectAll();
	}


	@RequestMapping("/recognizee/list/view")
	public ModelAndView listView(
			@RequestParam(defaultValue = "1") int current,
			@RequestParam(defaultValue = "10") int size,
			String name,
			String nature,
			String antiLaunGrade,
			String papersType,
			String papersNum,
			String address,
			String tel,
			ModelAndView modelAndView){
		modelAndView.setViewName("recognizee/list");
		List<Recognizee> RecognizeeList = service.selectPage(current,size,name,nature,antiLaunGrade,papersType,papersNum,address,tel);

		modelAndView.addObject("list",RecognizeeList);
		int count = service.selectPageCount(current,size,name,nature,antiLaunGrade,papersType,papersNum,address,tel);
		int totalCount = count%size==0?count/size:count/size+1;
		modelAndView.addObject("totalCount",totalCount);
		modelAndView.addObject("current",current);
		return modelAndView;
}}
